import axios from '../../plugins/axios.js'

const state = {
	home:[],
	banner:[]
}

const actions = {
	home({state,commit},{_limit,_page}={}){
		axios.get('/news/home',{params:{_limit:_limit||20,_page:_page||1}})
		.then(
			res=>{
				commit('home',res.data)
			}
		)
	},
	banner({state,commit},{_limit,_page}={}){
		axios.get('/news/banner',{params:{_limit:_limit||3,_page:_page||1}})
		.then(
			res=>{
				commit('banner',res.data)
			}
		)
	}
}

const mutations = {
	home:(state,payload)=>{
		state.home=payload
	},
	banner:(state,payload)=>{
		state.banner=payload
	}
}

export default {
	namespaced:true,
	state,actions,mutations
}